<style>
	.block-mb15{
		display: inline-block;margin-bottom: 15px;
	}
</style>
<div class="container-fluid" style="padding: 20px 10px 0px 10px">
	<div class="row-fluid">
		<div class="well">
		    <ul class="nav nav-tabs">
		      <li class="active"><b>jolly商品管理</b></li>
		    </ul>
		    <div id="myTabContent" class="tab-content">
				<div class="tab-pane active in" id="home">
					<form id="formid" action="/project/addJolly" method="post">
						<span class="block-mb15" style="margin-left: 13px;">商品名称：<input type="text" value="<?=$getData['jolly_name']?>" placeholder="商品名称" style="width:200px;margin-left: 5px;" name="jolly_name" class="jolly_name">
						</span>
						<!--<span class="block-mb15" style="margin-left: 13px;">购买所需积分类型：-->
							<!--<select name="score_type">-->
								<!--<option value="1" <?=$getData['score_type']==1?'selected':''?>>普通积分</option>-->
								<!--<option value="2" <?=$getData['score_type']==2?'selected':''?>>白金积分</option>-->
								<!--<option value="3" <?=$getData['score_type']==3?'selected':''?>>钻石积分</option>-->
							<!--</select>-->
						<!--</span><br>-->
						<span class="block-mb15" style="margin-left: 14px;">商品价格：<input type="text" value="<?=$getData['jolly_price']?>" style="width:200px;margin-left: 5px;" name="jolly_price" class="jolly_price">
						</span><br/>

						<span class="block-mb15" style="margin-left: 14px;"><div id="setImd" style="display:inline;">封面图片：<input type="text" name="face_img" class="setImdText" style="width:388px;margin-left: 4px;" value="<?=$getData['jolly_face_img']?>" readonly> <input type="button" class="btn btn-info setImdBtn" style='margin-top:-10px;' value="选择图片">&nbsp;<a class="btn btn-warning  picViews" <?=$getData['cover_img'] ? '' : 'disabled title="暂不可用"'?> url="<?=$getData['jolly_face_img'] ? transUrl($getData['jolly_face_img']) : ''?>" style='margin-top:-8px'>查看</a></div></span>
						</span></br>

						<span class="block-mb15" style="margin-left: 13px;">商品介绍：<textarea name="jolly_desc" style="height: 100px;width: 568px;margin-left: 75px;resize: none"><?=htmlspecialchars_decode($getData['jolly_desc'])?></textarea></span>
						<?php if($getData['jolly_detail_img']){foreach($getData['jolly_detail_img'] as $k=>$v){?>
						<span class="block-mb15" id="myi" style="margin-left: 14px;"><div id="setImd<?=$k+2?>" style="display:inline;">详情图片：<input type="text" name="detail_img[]" class="setImd<?=$k+2?>Text" style="width:388px;margin-left: 4px;" value="<?=$v?>" readonly> <input type="button" class="btn btn-info setImd<?=$k+2?>Btn" style="margin-top:-10px;" value="选择图片">&nbsp;<a class="btn btn-warning  picViews" <?=$v ? '' : 'disabled title="暂不可用"'?> url="<?=$v ? transUrl($v) : ''?>" style="margin-top:-8px">查看</a><input type="button" class="dis" value="增加" style="margin-left: 5px;width: 40px;height:30px;margin-top:-8px;"></div></span>
						</span></br>
						<?php }}else{?>
						<!--<span class="block-mb15" style="margin-left: 13px;">商品介绍：<textarea name="jolly_desc" style="height: 100px;width: 568px;margin-left: 75px;resize: none"><?=htmlspecialchars_decode($getData['jolly_desc'])?></textarea></span>-->
						<span class="block-mb15" id="myi" style="margin-left: 18px;"><div id="setImd2" style="display:inline;">详情图片：<input type="text" name="detail_img[]" class="setImd2Text" style="width:388px;margin-left: 0px;" value="<?=$getData['jolly_face_img']?>" readonly> <input type="button" class="btn btn-info setImd2Btn" style="margin-top:-10px;" value="选择图片">&nbsp;<a class="btn btn-warning  picViews" <?=$getData['cover_img'] ? '' : 'disabled title="暂不可用"'?> url="<?=$getData['jolly_face_img'] ? transUrl($getData['jolly_face_img']) : ''?>" style="margin-top:-8px">查看</a><input type="button" class="dis" value="增加" style="margin-left: 5px;width: 40px;height:30px;margin-top:-8px;"></div></span>
						</span></br>
						<?php }?>
						<span class="empty_s"></span>
						<input type="hidden" value="<?=$getData['jolly_id']?>" name="jolly_id">
						<input type="hidden" value="1" name="dosubmit" />
					</form>
				</div>
				<div class="btn-toolbar">
				    <button class="btn btn-primary" id="btn-save" style="margin:18px 0 0 88px"><i class="icon-save"></i> 保存</button>
				  <div class="btn-group">
				  </div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
$(function(){
	$('.setImdBtn').click(function(){
		$('#setImd').selfups();
	});
	$('.setImd2Btn').live('click',function(){
		$('#setImd2').selfups();
	});
	$('.setImd3Btn').live('click',function(){
		$('#setImd3').selfups();
	});
	$('.setImd4Btn').live('click',function(){
		$('#setImd4').selfups();
	});
	$('.setImd5Btn').live('click',function(){
		$('#setImd5').selfups();
	});
	$('.setImd6Btn').live('click',function(){
		$('#setImd6').selfups();
	});
	$('.setImd7Btn').live('click',function(){
		$('#setImd7').selfups();
	});
	$('.setImd8Btn').live('click',function(){
		$('#setImd8').selfups();
	});


	$('#btn-save').click(function(){
		if($('input[name="jolly_name"]').val() == ''){
				showmsg('请输入套餐名');
				return false;
		}else if(!checkPrice($('input[name="jolly_price"]').val())){
				showmsg('请输入正确的价格');
				return false;
		}else if($('input[name="face_img"]').val() == ''){
				showmsg('请选择套餐图片');
				return false;
		}else{
			$('#formid').submit();
		}
	});

    function checkNum(num)
    {
        var reg = /^[0-1]{1}(.[0-9]{0,2})?$/;
        if(reg.test(num)) {
            return true;
        }
        return false ;
    }

	function checkPrice(num){
		var reg = /^\d+(\.{1}\d{1,2})?$/;
		if(reg.test(num)) {
			return true;
		}
		return false ;
	}
})
</script>

<script>
	$(function(){
		$('.dis').live('click', function() {
			var len = $('.dis').length + 2;
			var idbn = 'setImd'+len;
			var clbn = 'setImd'+len+'Text';
			var bn = 'setImd'+len+'Btn';
			var html = '';
			html += '<span class="block-mb15" id="" style="margin-left: 14px;">';
			html += '<div id="' + idbn +'" style="display:inline;">详情图片：';
			html += '<input type="text" name="detail_img[]" class="' +clbn +'" style="width:388px;margin-left: 4px;" value="" readonly>';
			html += '<input type="button" class="btn btn-info ' + bn +'" style="margin-top:-10px;margin-left: 5px;" value="选择图片">&nbsp;';
			html += '<a class="btn btn-warning  picViews"';
			html += '';
			html += 'url=""';
			html += 'style="margin-top:-8px" >';
			html += '查看';
			html += '</a>';
			html += '<input type="button" class="dis" value="增加" style="margin-left: 5px;width: 40px;height:30px;margin-top: -8px;">';
			html += '</div>';
			html += '</span>';
			html += '<br>';
			$('.empty_s').before(html);
		});
		$('#remove').live('click', function() {
			$(this).prevAll().remove();
			$(this).remove();
		});
        $('#remove1').live('click', function() {
            $(this).parent().prev('input[type="hidden"]').remove();
            $(this).prevAll().remove();
            $(this).remove();
        });

		$('.myClass').on('keyup',function(){
            $(this).val($(this).val().replace(/[^\d]/g,''));
            var val = $(this).val();

			var old_val = $(this).parent().prev('input[type="hidden"]').val();
			var new_val = old_val.split(',')[0]+','+val;
			$(this).parent().prev('input[type="hidden"]').val(new_val);
		})

		$('input[name="mycard"]').live('keyup',function(){
			$(this).val($(this).val().replace(/[^\d]/g,''));
		})

		$('.jolly_price').on('keyup',function(){
			$(this).val($(this).val().replace(/[^\d]/g,''));
		})

	})
</script>